package com.wsq.retrofitdemo.retrofit;

import java.io.IOException;

import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Date:2021/9/2
 * Time:10:54
 * author:wushengqi
 */
public class AddQueryInterceptor implements Interceptor {
    private String sign;
    private String userId;
    public AddQueryInterceptor(String sign,String userId){
        this.sign = sign;
        this.userId = userId;
    }
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Request newRequest;
        HttpUrl httpUrl = request.url().newBuilder()
                .addQueryParameter("clientType", "2")
                .addQueryParameter("openId","5ff6a1f5")
                .addQueryParameter("sign",sign)
                .addQueryParameter("third_user_id",this.userId)
                .build();
        newRequest = request.newBuilder().url(httpUrl).build();
        return chain.proceed(newRequest);
    }
}
